﻿using System;
using System.Collections.Generic;
using Iesi.Collections.Generic;

namespace ScrumBox.Model
{
    public class Sprint : EntityBase
    {
        private DateTime? _endDate;
        private DateTime? _startDate;
        private string _title;
        private Project _project = new Project();
        private readonly ISet<SprintBackLogItem> _sprintBackLogItems = new HashedSet<SprintBackLogItem>();
        private readonly string _key;

        /// <summary>
        /// Key
        /// </summary>
        public virtual string Key
        {
            get { return _key; }
        }


        /// <summary>
        /// Title
        /// </summary>
        public virtual string Title
        {
            get { return _title; }
            set { _title = value; }
        }
        
        /// <summary>
        /// StartDate
        /// </summary>
        public virtual DateTime? StartDate
        {
            get { return _startDate; }
            set { _startDate = value; }
        }

        /// <summary>
        /// EndDate
        /// </summary>
        public virtual DateTime? EndDate
        {
            get { return _endDate; }
            set { _endDate = value; }
        }

        /// <summary>
        /// SprintBackLogItems
        /// </summary>
        public virtual IList<SprintBackLogItem> GetSprintBackLogItems()
        {
            return new List<SprintBackLogItem>(_sprintBackLogItems);
        }
        
        /// <summary>
        /// 
        /// </summary>
        public virtual Project Project
        {
            get { return _project; }
            set { _project = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        protected Sprint(){}

        /// <summary>
        /// 
        /// </summary>
        /// <param name="project"></param>
        public Sprint(Project project)
        {
            _project = project;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="title"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        public Sprint(string key, string title, DateTime startDate, DateTime endDate)
        {
            _key = key;
            _title = title;
            _startDate = startDate;
            _endDate = endDate;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        public virtual void AddBackLogItem(SprintBackLogItem item)
        {
            _sprintBackLogItems.Add(item);
        }
    }
}